package com.yvan.serverless.script.internal;

import com.yvan.serverless.script.internal.support.GraalObjectToString;

import java.util.concurrent.ExecutionException;

/**
 * 作者：lizw <br/>
 * 创建时间：2020/07/26 15:20 <br/>
 */
public class GraalLoggerFactory extends LoggerFactory {
    public static final GraalLoggerFactory Instance = new GraalLoggerFactory();

    protected GraalLoggerFactory() {
    }

    /**
     * 获取日志对象
     *
     * @param name 名称
     */
    public Logger getLogger(String name) {
        try {
            return Logger_Cache.get(name, () -> {
                Logger logger = new Logger(name);
                logger.setObjectToString(GraalObjectToString.Instance);
                return logger;
            });
        } catch (ExecutionException e) {
            throw new RuntimeException(e);
        }
    }
}
